package com.kotlin.flong.base

import java.util.HashMap

/*
 * map的使用
 */
fun main(args : Array<String>){
	mapOf1()
}


fun mapOf1(){

	//不可变
	var map1 = mapOf("age" to 29,"userName" to "寅务")

	val mapSet1 = map1.keys

	mapSet1.forEach{
		println(it)
	}

	val mapSet2 = map1.values;

	mapSet2.forEach{
		println(it)
	}

	val mapSet3 = map1.entries

	//val是关键字故要用·引号
	map1.forEach { key,`val` ->
		//println("key=$key,value=$`val`")
	}


	for((key,value) in map1){
		println("key=$key,value=$`value`")
	}

	//可变
	//var map2 = mutableMapOf();

	//java 的map

	var map3 = HashMap<String,String>()

	map3.put("age","23");
	map3.put("userName","寅务");

	for(m3 in map3){
		println(m3.key + "," + m3.value)
	}


}





